#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = 30005;
const int maxm = 1000000;
int head[maxn],n,m,num_edge,lx[maxn];
int d[maxn],p[maxn][30];

struct node{
	int next;
	int to;
}edge[maxm];

void add_edge(int from,int to){
	num_edge++;
	edge[num_edge].next=head[from];
	edge[num_edge].to=to;
	head[from]=num_edge;
}

void dfs(int u){
	for(int i=head[u];i!=0;i=edge[i].next){
		int to=edge[i].to;
		if(to==p[u][0])continue;
		d[to]=d[u]+1;
		p[to][0]=u;
		dfs(to);
	}
}

void init(){
	for(int j=1;(1<<j)<=n;j++){
		for(int i=1;i<=n;i++){
			p[i][j]=p[p[i][j-1]][j-1];
		}
	}
}

int lca(int a,int b){
	if(d[a]>d[b])swap(a,b);
	int f=d[b]-d[a];
	for(int i=0;(1<<i)<=f;i++){
		if((1<<i)&f)b=p[b][i];
	}
	if(a!=b){
		for(int i=(int)log2(n);i>=0;i--){
			if(p[a][i]!=p[b][i]){
				a=p[a][i];b=p[b][i];
			}
		}
	}else return a; 
	return p[a][0];
}

int main(){
	cin>>n;
	int x,y;
	for(int i=1;i<=n-1;i++){
		cin>>x>>y;
		add_edge(x,y);
		add_edge(y,x); 
	}
	d[1]=0;
	for(int i=1;i<=n;i++)p[i][0]=i;
	dfs(1);
	init();
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>lx[i];
	}
	int ans=0;
	for(int i=1;i<m;i++){
		int fa; 
		fa=lca(lx[i],lx[i+1]);
		//cout<<fa<<endl;
		ans+=d[lx[i]]+d[lx[i+1]]-2*d[fa];
	}
	cout<<ans<<endl;
	return 0;
}
